package com.example.rubbish.Utils;

import com.example.rubbish.gson.Hot;
import com.example.rubbish.gson.Result;
import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;
public class JsonUtils {
    public static Result handleInfoResponse(String response) {

        try {
            JSONObject jsonObject = new JSONObject(response);
            JSONObject jsonObject1 = jsonObject.getJSONObject("result");
            String resultContent =jsonObject1.toString();
            return new Gson().fromJson(resultContent, Result.class);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
    public static Hot handleHotResponse(String response) {
        try {
            JSONObject jsonObject = new JSONObject(response);
            String resultContent =jsonObject.toString();

            Hot hot = new Gson().fromJson(resultContent, Hot.class);

            return hot;
        } catch (JSONException e) {
            e.printStackTrace();
        }
        return null;
    }
}
